/*
 * @Author: 谢陈洁
 * @Date: 2025-07-23 14:41:44
 * @LastEditors: 谢陈洁
 * @LastEditTime: 2025-07-23 15:58:25
 * @Description: file content
 */
export const formConfig = [
  {
    label: '用户名',
    prop: 'username',
    span: 24,
    rules: [
      {
        required: true,
        message: '请输入用户名',
        trigger: 'blur'
      }
    ]
  },
  {
    label: '昵称',
    prop: 'nickname',
    span: 24,
    rules: [
      {
        required: true,
        message: '请输入昵称',
        trigger: 'blur'
      }
    ]
  },
  {
    label: '邮箱',
    prop: 'email',
    span: 24,
    rules: [
      {
        type: 'email',
        message: '请输入正确的邮箱',
        trigger: ['blur', 'change']
      }
    ]
  },
  {
    label: 'qq',
    prop: 'qq',
    span: 24,
  }, {
    label: '头像',
    prop: 'avatar',
    span: 24,
    type:'upload',
    attrs:{
      limit:1,
      multiple:false
    }
  }
]
export const passwordFormConfig = [
  {
    label: '旧密码',
    prop: 'oldPassword',
    span: 24,
    type: 'password',
    attrs: {
      type: 'password',
      showPassword: true
    },
    rules: [
      {
        required: true,
        message: '请输入旧密码',
        trigger: ['blur', 'change']
      }
    ]
  },
  {
    label: '新密码',
    prop: 'newPassword',
    span: 24,
    type: 'password',
    attrs: {
      type: 'password',
      showPassword: true
    },
    rules: [
      {
        required: true,
        message: '请输入新密码',
        trigger: ['blur', 'change']
      },{
        min: 6,
        max: 20,
        message: '密码长度在 6 到 20 个字符',
        trigger: ['blur', 'change']
      }, {
        validator: (rule: any, value: string, callback: any, formData: Record<string, any>) => {
          if (value === formData.oldPassword) {
            callback(new Error('新密码不能与旧密码相同'))
          } else {
            callback()
          }
        },
      }
    ]
  },
  {
    label: '确认新密码',
    prop: 'confirmNewPassword',
    span: 24,
    type: 'input',
    attrs: {
      type: 'password',
      showPassword: true
    },
    rules: [
      {
        required: true,
        message: '请输入确认新密码',
        trigger: ['blur', 'change']
      },
      {
        validator: (rule: any, value: string, callback: any, formData: Record<string, any>) => {
          console.log(rule, value, callback, formData)
          if (value !== formData.newPassword) {
            callback(new Error('两次输入的密码不一致'))
          } else {
            callback()
          }
        },
        trigger: ['blur', 'change']
      }
    ]
  }
]
